//#include <stdio.h>
//
//#define MAX_SIZE 1005
//
//int main() 
//{
//    int n, m, q;
//    scanf_s("%d %d %d", &n, &m, &q);
//    long long a[MAX_SIZE][MAX_SIZE] = { 0 };
//    long long pref[MAX_SIZE][MAX_SIZE] = { 0 };
//
//    for (int i = 1; i <= n; i++)
//    {
//        for (int j = 1; j <= m; j++) 
//        {
//            scanf_s("%lld", &a[i][j]);
//        }
//    }
//
//    for (int i = 1; i <= n; i++) 
//    {
//        for (int j = 1; j <= m; j++) 
//        {
//            pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + a[i][j];
//        }
//    }
//
//    while (q--) 
//    {
//        int x1, y1, x2, y2;
//        scanf_s("%d %d %d %d", &x1, &y1, &x2, &y2);
//        long long ans = pref[x2][y2] - pref[x1 - 1][y2] - pref[x2][y1 - 1] + pref[x1 - 1][y1 - 1];
//        printf("%lld\n", ans);
//    }
//
//    return 0;
//}

#include <stdio.h>
#include <stdlib.h>

int main() 
{
    int n, m, q;
    scanf_s("%d %d %d", &n, &m, &q);
    long long** diff = (long long**)malloc((n + 2) * sizeof(long long*));
    for (int i = 0; i < n + 2; i++)
    {
        diff[i] = (long long*)calloc(m + 2, sizeof(long long));
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++) 
        {
            long long x;
            scanf_s("%lld", &x);
            diff[i][j] += x;
            diff[i][j + 1] -= x;
            diff[i + 1][j] -= x;
            diff[i + 1][j + 1] += x;
        }
    }

    while (q--) 
    {
        int x1, y1, x2, y2;
        long long k;
        scanf_s("%d %d %d %d %lld", &x1, &y1, &x2, &y2, &k);
        diff[x1][y1] += k;
        diff[x1][y2 + 1] -= k;
        diff[x2 + 1][y1] -= k;
        diff[x2 + 1][y2 + 1] += k;
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++) 
        {
            diff[i][j] += diff[i - 1][j] + diff[i][j - 1] - diff[i - 1][j - 1];
        }
    }

    for (int i = 1; i <= n; i++) 
    {
        for (int j = 1; j <= m; j++)
        {
            printf("%lld", diff[i][j]);
            if (j < m)
            {
                printf(" ");
            }
        }
        printf("\n");
    }

    for (int i = 0; i < n + 2; i++)
    {
        free(diff[i]);
    }
    free(diff);
    return 0;
}